package week3.example;//****************************************************************************************************************
//   Quadratic.java         Author:Duanzhixuan
//
//  Demonstrates the use of the Math class to perform a conculation based on user input.
//*****************************************************************************************************************
import java.util.Scanner;

 public class E3_3
{
//****************************************************************************************************************
//  Determines the roots of a quadratic equation.
//****************************************************************************************************************
  public static void main(String[] args)
 {
 int a,b,c;  //ax^2 + bx + c
 double discriminant,root1,root2;
 

Scanner scan = new Scanner(System.in);

System.out.print("Enter the cofficient of x squared: ");
a = scan.nextInt();

System.out.print("Enter the cofficient of x:");
b= scan.nextInt();

System.out.print("Enter the constant:");
c = scan.nextInt();

//Use the quadratic formula to compute the roots.
//Assumes a postive discriminant



discriminant = Math.pow(b,2) - (4*4*c);
root1 =((-1*b) + Math.sqrt(discriminant))/ (2*a);
root2 =((-1*b) - Math.sqrt(discriminant))/ (2*a);

System.out.println("Root #1: " + root1);
System.out.println("Root #2: " + root2);
}
}

